
export const Color = {
  getRandomRgb: (rp: boolean = false) => {
    let r = Math.floor(Math.random() * (255 - 0) + 1);
    let g = Math.floor(Math.random() * (255 - 0) + 1);
    let b = Math.floor(Math.random() * (255 - 0) + 1);
    let a: string | number = Math.random().toFixed(2);
    if (!rp) a = 1;
    return `rgba(${r}, ${g}, ${b}, ${a})`;
  },
  getRandom16Color() {
      const rgba = this.getRandomRgb();
      let rgbArr = rgba.match(/\d+/g);
      let res = '#';
      if (rgbArr.length > 3) {
          rgbArr.splice(3, rgbArr.length - 3);
      };
      rgbArr.forEach(item => {
          // 核心代码
          res += ('0' + Number(item).toString(16)).slice(-2);
          // res += (Number(item) > 16 ? '' : '0') + Number(item).toString(16);
          // res += Number(item).toString(16).padEnd(2, '0');
      });
      return res;
  }

}